Retrieving Warning Information
The data providers handle database server warnings through the InfoMessage delegates on the Connection objects.
The following example shows how to retrieve a warning from a Sybase server:
// Define an event handler public void myHandler(object sender, SequeLinkInfoMessageEventArgs e) { // Display any warnings in a messagebox MessageBox.Show (e.Message,"This is a Warning."); }Add the following code to a method and call it:
SequeLinkConnection Conn; Conn = new SequeLinkConnection("host=bowhead;port=19996;User ID=test01; Password=test01"); SequeLinkCommand DBCmd = new SequeLinkCommand("print 'This is a warning.'", Conn); SequeLinkDataReader myDataReader; try { Conn.InfoMessage += new SequeLinkInfoMessageEventHandler(myHandler); Conn.Open(); myDataReader = DBCmd.ExecuteReader(); // This will throw a SequeLinkInfoMessageEvent as the print // statement generates a warning. } catch (Exception ex) { // Display any exceptions in a messagebox MessageBox.Show (ex.Message); } // Close the connection Conn.Close();